package com.zimin.cloud.user.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zimin.cloud.mine.pojo.user.business.FollowingGroupBO;
import com.zimin.cloud.mine.pojo.user.business.UserFollowingBO;
import com.zimin.cloud.mine.pojo.user.business.UserInfoBO;
import com.zimin.cloud.user.biz.IUserBiz;
import com.zimin.cloud.user.biz.IUserFollowingBiz;
import com.zimin.cloud.user.common.util.ServletUtil;
import com.zimin.cloud.user.pojo.entity.UserInfo;
import com.zimin.shared.pojo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;
import com.zimin.shared.pojo.BaseController;
import com.zimin.cloud.user.controller.api.IUserFollowingController;

/**
 * <p>
 * 用户关注表 前端控制器
 * </p>
 *
 * @author zimin
 * @since 2022-06-14 16:10
 */
@RestController
public class UserFollowingController extends BaseController implements IUserFollowingController {

    @Autowired
    private IUserFollowingBiz userFollowingBiz;
    @Autowired
    private IUserBiz userBiz;

    @Override
    public Result addUserFollowings(UserFollowingBO userFollowingBO) {
        var userId = ServletUtil.getCurrentUserId();
        userFollowingBO.setUserId(userId);
        return result(userFollowingBiz.addUserFollowings(userFollowingBO));
    }

    @Override
    public Result getUserFollowings() {
        var userId = ServletUtil.getCurrentUserId();
        return result(userFollowingBiz.getUserFollowing(userId));
    }

    @Override
    public Result getUserFans() {
        var userId = ServletUtil.getCurrentUserId();
        return result(userFollowingBiz.getUserFans(userId));
    }

    @Override
    public Result addUserFollowingGroups(FollowingGroupBO followingGroupBO) {
        var userId = ServletUtil.getCurrentUserId();
        followingGroupBO.setUserId(userId);
        return result(userFollowingBiz.save(followingGroupBO));
    }

    @Override
    public Result getUserFollowingGroups() {
        var userId = ServletUtil.getCurrentUserId();
        return Result.ok(userFollowingBiz.getUserFollowingGroups(userId));
    }

}
